// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

import $ from 'jquery'
import 'bootstrap'
import vueLazyLoad from 'vue-lazyload'
// 引入bootstrap样式
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap/dist/js/bootstrap.min.js'

import './assets/css/screen.css'
import './assets/css/animation.css'
import './assets/css/font-awesome.css'
import './assets/css/lity.css'
import './assets/css/mystyle.css'
import './assets/css/404.css'

import axios from 'axios'
import qs from 'qs'
import store from './store'

import * as filters from './js/my-filter'
Object.keys(filters).forEach(key => Vue.filter(key, filters[key]))

// 全局注册 $
Vue.prototype.$ = $

Vue.config.productionTip = false

router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

/* 配置axios */
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'
Vue.prototype.$axios = axios

/* 配置qs */
Vue.prototype.$qs = qs

/* 图片懒加载 */
Vue.use(vueLazyLoad, {
  error: './static/img/error.jpg', // 报错需要的图片
  loading: './static/img/loading.gif' // 替换需要的图片
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store: store,
  components: {App},
  template: '<App/>'
})
